import java.util.concurrent.CompletableFuture;
/**
 * @author jekyllxv
 */
public class CompleteFutureTest {
    public static void main(String[] args) {
        CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
            try {
                // 模拟长时间执行的任务
              System.out.println(Thread.currentThread().getName()) ;
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return "Hello, CompletableFuture!";
        });
        future.thenAccept(result -> {
            System.out.println(result);
        });
        // 等待CompletableFuture完成
        future.join();
    }
}